home *** CD-ROM | disk | FTP | other *** search
- Path: mailhub.scitec.com.au!ramsesy
- From: ramsesy@rd.scitec.com.au (Ramses Youhana)
- Newsgroups: comp.lang.c
- Subject: Re: sscanf bug??????
- Date: 22 Feb 1996 07:53:16 GMT
- Organization: SCITEC LIMITED, Sydney, Australia.
- Message-ID: <4gh7dc$i2@mailhub.scitec.com.au>
- References: <4fimvo$82s@fnord.dfw.net> <4fqfeo$7mh@umbc9.umbc.edu>
- NNTP-Posting-Host: scitec7.scitec.com.au
- X-Newsreader: TIN [version 1.2 PL2]
-
- Jonas J. Schlein (schlein@umbc.edu) wrote:
- > Jerry Jackson <jtmcap@dfw.dfw.net> wrote:
- > |> the following is a program compiled using microway ndp c/c++ compiler.
-
- > "Compiler produces an executable" != "Your program was correct"
-
- > |> #include <stdio.h>
- > |> #include <string.h>
- > |>
- > |> main()
- > |> {
- > |> char str_1[] = "013196";
- > |> char str_2[] = "13196";
- > |> long res_1, res_2;
- > |>
- > |> sscanf(str_1,"%d",&res_1);
- > |> sscanf(str_2,"%d",&res_2);
-
- > <SNIP>
-
- > And don't forget:
-
- > return (0);
-
-
- > <SNIP>
-
- It is also good practice to specify the parameters to a function and its
- return values. This forces an ANSI-C compiler to perform some degree of
- parameter and return type checking, hopefully picking up some bugs at
- compile time and saving you from lots of headaches during debugging.
-
- E.g.
-
- int main (void)
-
- instead of
-
- main()
-
-
-